﻿<!DOCTYPE html>
<html>
<head>
    <title>CGI</title>
</head>
<body>
    <h1>Our Page</h1>
    <script>
        //01
        
        var value = !true;
        console.log(value);

        //numeric value evaluates to true other than zero
        var value = !99;
        console.log(value);

        //if anything in string, evaluates to true
        var value = !"";
        console.log(value);

        var value = !"A";
        console.log(value);

        //new object retrun object, evaluates to true
        var value = !new Object();
        console.log(value);

        var value = !null;
        console.log(value);

        var value = !undefined;
        console.log(value);

        var value = !NaN;
        console.log(value);
        

        //02
        //converted into boolean value
        /*
        var value = !!false;
        console.log(value);
        */

        //03
        //&& operator evaluates true, when both true
        /*
        var value = true && true;
        console.log(value);
        */

        //04
        //object and any value for &&, any value will be returned
        /*
        var obj = {
            calc: 'Logical AND'
        };

        var value = obj && 99;
        console.log(value);

        var value = obj && obj;
        console.log(value);

        var value = true && obj;
        console.log(value);
        */

        //05
        //either one operand is null, then null returns
        /*
        var value = null && 99;
        console.log(value);

        var value = "Z" && undefined;
        console.log(value);

        var value = "Z" && NaN;
        console.log(value);
        */

        //06
        //2nd operand ignored as this is undefined
        /*
        var value = false && productId;
        console.log(value);
        */

        //07
        //true, if either operand is true
        /*
        var value = true || true
        console.log(value);

        var value = false || false;
        console.log(value);
        */

        //07
        //2nd operand is completely ignored, hence OBJ will be returned
        /*
        var obj = {
            calc: 'LogicalOR'
        };

        var value = obj || 99;
        console.log(value);
        */

        //08
        //if userSettings doesn't have any settings, defaultSettings will return (real use example)
        /*
        var defaultSettings = {
            who: 'default'
        };

        var userSettings = {
            who: 'user'
        };

        //var userSettings;

        var value = userSettings || defaultSettings;
        console.log(value);
         */
    </script>
</body>
</html>